package com.daoyin.ssph.frontAction;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.daoyin.ssph.bean.Honor;
import com.daoyin.ssph.service.HonorService;
import com.daoyin.ssph.tools.MyPagination;


public class HonorAction {
	private HonorService ha;
	private String id;
	public void setId(String id) {
		this.id = id;
	}
	
	public void setHa(HonorService ha) {
		this.ha = ha;
	}

	HttpServletRequest request = null;
	MyPagination pagination = new MyPagination();
	public String show(){
		request = ServletActionContext.getRequest();
		
		List<Honor> list = ha.query();
		for(int i = 0; i < list.size(); i++){
			if(list.get(i).getPublish() == 0){
				list.remove(i);
			}
		}
		String str=(String)request.getParameter("Page");
		int p=1;
		list=pagination.getInitPage(list,1,9);
		p=pagination.getPage(str);
		list=(ArrayList)pagination.getAppointPage(p);
		String pages = pagination.printCtrl(p);
		
		request.setAttribute("show", list);
		return "success";

	}
}
